<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function check_verifycode(){
    $account = $_POST['account'];
    $pass = $_POST['password'];
    $veri = $_POST['verify'];
    if(empty($account)) {
      $this->error('帐号错误！');
    }elseif (empty($pass)){
      $this->error('密码必须！');
    }elseif (empty($veri)){
      $this->error('验证码必须！');
    }
    $m = M('admin');
    $msguser = $m->where("username = '$account'")->find();
    $verify = $_POST['verify'];
    if(!check_verify($verify)){  
        $this->error("亲，验证码输错了哦！");  
    }
    if($msguser['password'] == $pass){
        session("admin", $account);
        $this->success("登录成功", __APP__."/Home/Index/index");
    }else{
        $this->error("用户名或密码错误");
    }   
    }
    public function index(){
       $this->display();
    }
    #验证码生成
    public function verify_c(){
        $Verify = new \Think\Verify();
        $Verify->fontSize = 18;
        $Verify->length = 4;
        $Verify->useNoise = true;
        $Verify->codeSet = '0123456789';  
        $Verify->imageW = 130;  
        $Verify->imageH = 50;  
        //$Verify->expire = 600;  
        $Verify->entry(); 
    }
    
   }

?>
